﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace FormShow
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void ThreadFunc()
        {
            MethodInvoker mi = new MethodInvoker(this.ShowMsgForm);
            this.BeginInvoke(mi);
        }

        private void ShowMsgForm()
        {
            string value = string.Empty;
            using (Form2 frm = new Form2())
            {
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    //value就是Form2关闭的时候传出的
                    value = frm.OutValue;
                }
            }

            MessageBox.Show(value);
        } 

        private void button1_Click(object sender, EventArgs e)
        {
            Thread FormThread = new Thread(new ThreadStart(ThreadFunc));
            FormThread.Start();  
        }
    }
}
